#include <stdio.h>
#include <string.h>
#define N 20

char tu[N][N], tu2[N][N], tu3[N][N];
int  n, m, length;
int  ans;
int  movex[]={1,-1,0,0, 1,1,-1,-1};
int  movey[]={0,0,1,-1, 1,-1,1,-1};
int  tot1, tot2, tot3;

bool changetu()
{
	int x, y, tox, toy, k, cnt;

	tot2 = 0;
	for (x=0; x<n; ++x)
		for (y=0; y<m; ++y)
		{
			cnt = 0;
			for (k=0; k<8; ++k)
			{
				tox = x + movex[k];
				toy = y + movey[k];
				if (tox<0) tox = n-1;
				if (tox==n) tox = 0;
				if (toy<0) toy = m-1;
				if (toy==m) toy = 0;
				
				//if (tu[tox][toy] == 1 && !(tox==x && toy==y)) ++cnt;
				if (tu[tox][toy] == 1 ) ++cnt;
			}
			if (cnt == 3) tu2[x][y] = 1;
			else if (cnt == 2) tu2[x][y] = tu[x][y];
			else tu2[x][y] = 0;
			// compare
			if (tu2[x][y] != tu3[x][y]) return false;
		}
		return true;
}

void check()
{
	if (changetu())	
	{
	//	output();
		++ans;
	}
}
void di(int pt)
{
	int x, y;
	if (pt==length)
	{
		check();
		return;
	}
	x = pt/m;
	y = pt%m;
	tu[x][y] = 0;
	di(pt+1);
	tu[x][y] = 1;
	di(pt+1);
}

bool in()
{
	int i, k, x, y;

	scanf("%d%d", &n, &m);
	length = n*m;
	if (n==0 && m==0) return false;
	scanf("%d", &k);

	memset(tu3, 0, sizeof(tu3));
	memset(tu, 0, sizeof(tu));

	for (i=1; i<=k; ++i)
	{
		scanf("%d%d", &x, &y);
		tu3[x][y] = 1;
	}
	tot3 = k;
	return true;
}
int main()
{
	int ncase=0;
	while (in())
	{
		ans = 0;
		di(0);
		
		if (ans!=0)
			printf("Case %d: %d possible ancestors.\n", ++ncase, ans);
		else 
			printf("Case %d: Garden of Eden.\n", ++ncase);
	}

	return 0;
}
